package com.neusoft.elm.View.impl;

import java.util.List;
import java.util.Scanner;

import com.neusoft.elm.View.BusinessView;
import com.neusoft.elm.dao.BusinessDao;
import com.neusoft.elm.dao.impl.BusinessDaoImpl;
import com.neusoft.elm.po.Business;

public class BusinessViewImpl implements BusinessView {
	private Scanner input = new Scanner(System.in);
	

	public void listBusinessAll(){
		BusinessDao dao = new BusinessDaoImpl();
		
		
		List<Business> list = dao.listBusiness();
		System.out.println("商家编号\t商家名称\t商家地址\t商家介绍\t起送费\t配送费");
		for(Business business : list){
			System.out.println(business.getBusinessId()+"\t"
					+business.getBusinessName()+"\t"
					+business.getBusinessAddress()+"\t"
					+business.getBusinessExplain()+"\t"
					+business.getStarPrice()+"\t"
					+business.getDeliveryPrice()
		
					);
		}
	}
	
	
	public void listBusiness(){
		String businessName="";
		String businessAddress = "";
		String inputStr = "";
		System.out.println("是否需要输入商家关键词(y/n):");
		inputStr = input.next();
		if(inputStr.equals("y")){
			System.out.println("请输入商家名字关键字:");
			businessName = input.next();
			
			
		}
		
		System.out.println("是否需要输入地址关键词(y/n):");
		inputStr = input.next();
		if(inputStr.equals("y")){
			System.out.println("请输入商家地址关键字:");
			businessAddress = input.next();
		}
		
		BusinessDao dao = new BusinessDaoImpl();
		List<Business> list = dao.listBusiness(businessName,businessAddress);
		System.out.println("商家编号\t商家名称\t商家地址\t商家介绍\t起送费\t配送费");
		for(Business business : list){
			System.out.println(business.getBusinessId()+"\t"
					+business.getBusinessName()+"\t"
					+business.getBusinessAddress()+"\t"
					+business.getBusinessExplain()+"\t"
					+business.getStarPrice()+"\t"
					+business.getDeliveryPrice()
		
					);
		}
		
		
		
		
		
	}
	
	
	
	
	
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
